package com.jia.together.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jia.together.entity.Guide;
import com.jia.together.mapper.GuideMapper;
import com.jia.together.service.GuideService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dujiajia
 * @since 2021-02-19
 */
@Service
public class GuideServiceImpl extends ServiceImpl<GuideMapper, Guide> implements GuideService {

    @Override
    public Map<String,Object> listPage(Long pageNum, Long pageSize) {

        Page<Guide> page = new Page<>(pageNum,pageSize);
        QueryWrapper<Guide> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("gmt_create");
        Page<Guide> guidePage = baseMapper.selectPage(page, wrapper);
        List<Guide> records = guidePage.getRecords();
        long total = guidePage.getTotal();
        Map<String,Object> map = new HashMap<>();
        map.put("records",records);
        map.put("total",total);
        return map;
    }
}
